Learning Flex Basics (Part 2): Creating a Simple Calculator with Macromedia Flex
Table of Contents
- Introduction
- Building the Calculator
- Create the Application Object
- Add a Panel for the Calculator
- Add the Calculator Display
- Add a Grid to Lay Out the Buttons
- Add the Calculator Buttons
- Create the CalculatorController Class
- Add Properties to the Controller Class
- Add Controller Methods
- Instantiate the CalculatorController Class
- Complete Code Listing for calculator.mxml
- Complete Code Listing for CalculatorController.as
- Where to Go From Here
Add the Calculator Display
The Label element displays a single line of text. It has a number of properties; here, you will use the following properties:
- id: a unique identifier used to reference this instance in an event handler
- width: width of label in pixels
- text: text to display
- textAlign: horizontal alignment of text: left | right | center
-
Inside the Panel block, add a Label with the properties as follows:
<mx:Label id="calcDisplay" width="150" textAlign="right" />
Note: There is no text value in this tag because you will set the value with handler methods in the controller class; you build that functionality later in the tutorial.